<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" href="layui/css/layui.css" media="all"/>
		<style>
			.input_span_hidden{
				border: 0px;
				padding-top:10px;
			}
		</style>
			<!-- Metas -->
		    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
		    <meta name="viewport" content="width=device-width, initial-scale=1.0">
		    <meta name="author" content="Vision" />
		    <!-- Links -->
		    <link rel="icon" type="image/png" href="images/favicon.png" />
		    <link href="https://fonts.googleapis.com/css?family=Work+Sans:400,600&display=swap" rel="stylesheet">
		    <link rel="stylesheet" href="icofont.min.css">
		    <link href="css/bootstrap.min.css" rel="stylesheet" />
		    <link href="css/slick.css" rel="stylesheet" />
		    
		    <link href="css/main.css" rel="stylesheet" />
			<title></title>
			<link rel="stylesheet" href="layui/css/layui.css"/>
		</head>
		<body>
		<header id="home">
		<div class="container">
		  <nav class="navbar navbar-expand-lg navbar-light ">
		    <!-- Change Logo Img Here -->
		    <a class="navbar-brand" href="#"><img src="images/logo.svg" alt=""></a>
		    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
		      <div class="interactive-menu-button">
		        <a href="#">
		          <span>Menu</span>
		        </a>
		      </div>
		    </button>
		    <div class="collapse navbar-collapse" id="navbarSupportedContent">
		      <ul class="navbar-nav mr-auto">
		        <li class="nav-item">
		          <!-- Nav Link -->
		          <a class="nav-link" data-scroll href="index.html">主页.<span class="sr-only">(current)</span></a>
		        </li>
		        <li class="nav-item">
		          <!-- Nav Link -->
		          <a class="nav-link" data-scroll href="food.html">食品.</a>
		        </li>
		        <li class="nav-item">
		          <!-- Nav Link -->
		          <a class="nav-link" data-scroll href="batch.html">批次.</a>
		        </li>
		        <li class="nav-item">
		          <!-- Nav Link -->
		          <a class="nav-link active" data-scroll href="user.html">人员管理.</a>
		        </li>
		        <li class="nav-item">
		          <!-- Nav Link -->
		          <a class="nav-link" data-scroll href="about.html">关于我们.</a>
		        </li>
				<li class="nav-item">
				  <!-- Nav Link -->
				  <a class="nav-link" data-scroll href="log.html">日志.</a>
				</li>
		        <!-- <li class="nav-item dropdown">
		         
		          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">EN</a>
		          <div class="dropdown-menu" aria-labelledby="navbarDropdown">
		            <a class="dropdown-item" href="#">DE </a>
		            <a class="dropdown-item" href="#">ES </a>
		          </div>
		        </li> -->
		      </ul>
		      <a data-scroll href="my.html" class="contact-btn form-inline my-2 my-lg-0">
		        <!-- Contacgt Us Button -->
		        <button>个人信息</button>
		      </a>
		    </div>
		  </nav>
		</div>
		</header>
		<div style="padding: 0 250px;">
			
		
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		  <legend>个人信息</legend>
		</fieldset>
		 
		<form class="layui-form">
		  <div class="layui-form-item">
		    <label class="layui-form-label">姓名</label>
		    <div class="layui-input-block">
		      <input type="text" id="name" name="name" lay-verify="required|name" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">手机号</label>
		    <div class="layui-input-block">
		      <span type="text" id="phone" class="layui-input input_span_hidden"></span>
		    </div>
		  </div>
		  
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">性别</label>
		    <div class="layui-input-block">
		      <input type="radio" name="gender" value="男" title="男" checked="">
		      <input type="radio" name="gender" value="女" title="女">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">年龄</label>
		    <div class="layui-input-block">
		      <input type="number"  id="age" name="age" lay-verify="required|age" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">职位</label>
		    <div class="layui-input-block">
		      <input type="text" id="position" name="position" lay-verify="required|position" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">证件编号</label>
		    <div class="layui-input-block">
		      <input type="text" id="certificates" name="certificates" lay-verify="required|certificates" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">注册人</label>
		    <div class="layui-input-block">
		      <span type="text" id="referrer"  class="layui-input input_span_hidden"></span>
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">注册时间</label>
		    <div class="layui-input-block">
		      <span type="text" id="registertime"  class="layui-input input_span_hidden"></span>
		    </div>
		  </div>
		  <!-- <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">普通文本域</label>
		    <div class="layui-input-block">
		      <textarea placeholder="请输入内容" class="layui-textarea"></textarea>
		    </div>
		  </div> -->
		  
		  
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
		      
		    </div>
		  </div>
		</form>
		</div>
		
		
	</body>
	<script src="layui/layui.js"></script>
	<script>
	layui.use(['form', 'layedit', 'laydate'], function(){
	  var form = layui.form
	  ,$ = layui.$
	  ,layer = layui.layer
	  ,layedit = layui.layedit
	  ,laydate = layui.laydate;
	  
	  //请求个人信息数据
	  $.ajax({
		url: 'http://localhost:8080/foodman/admin/findById',
		type: 'GET',
		async: false,
		xhrFields: {withCredentials: true},
		crossDomain: true,
		processData: false, 
		contentType: false, 
		success: function (info) {
		  
			$('#name').val(info.name)
			$('#phone').html(info.phone)
			if(info.gender == '女'){
				$("input[name=gender][value=男]").prop("checked","false");
				$("input[name=gender][value=女]").prop("checked","true");
			}
			form.render();
			$('#age').val(info.age)
			$('#position').val(info.position)
			$('#certificates').val(info.certificates)
			$('#referrer').html(info.referrer)
			$('#registertime').html(info.registertime)
			
		}
	  });
	  
	  //创建一个编辑器
	  var editIndex = layedit.build('LAY_demo_editor');
	 
	  //自定义验证规则
	  form.verify({
	    name: function(value){
	      if(value.length < 4){
	        return '标题至少得4个字符啊';
	      }
	    }
	    ,age: function(value){
	      if(value < 1 || value > 100){
	        return '年龄不正确，检查一下';
	      }
	    }
	    ,content: function(value){
	      layedit.sync(editIndex);
	    }
	  });
	  
	  
	  //监听提交
	  form.on('submit(demo1)', function(data){
		data = data.field
	    $.ajax({
	          url: 'http://localhost:8080/foodman/admin/updateInfo',
	    	  async: false,
	    	  xhrFields: {withCredentials: true},
	    	  crossDomain: true,
	    	  
	          type: 'POST',
	          data: data,
	          success: function (info) {
	              if (info.code === 200) {
	                layer.msg(info.msg);
	                  // setTimeout(function () {
	                  //     location.href = 'login.html'
	                  //   }, 800);
	              }else{
	                layer.msg(info.msg);
	              }
	          }
	    });
	    return false;
	  });
	 
	
	  
	  
	  
	});
	</script>
</html>
